package cn.chint.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.chint.manage.service.MsgenterService;
import cn.chint.po.MsgEnter;

public class LoadDataServlet  extends HttpServlet{

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
 this.doPost(request, response)  ;
 
 
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		PrintWriter out = response.getWriter();
		out.print("返回servlet message");
	}
 
	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		
		long start = System.currentTimeMillis();
		System.out.println();
		System.out.println("***************容器初始化开始,查询所有项目名称*************");
		System.out.println("***************作用为避免匹配相似度的时候，每次查询所有记录*****");
		System.out.println("***************项目表数据量达到一定量的时候，查询缓慢,所有提前查询放入缓存***********");
		System.out.println("***************新增项目提交的时候，存入数据库，同时也存入缓存***********");
		MsgenterService msgenterService   = (MsgenterService) SpringContextUtil.getBean("msgenterService");
		List<MsgEnter> ls = msgenterService.Select("", "");  
		
		System.out.println("***************数据库中项目的记录数量："+ls.size()+"条*******************");
		for(MsgEnter msgEnter:ls){
		     Common.ls.add(msgEnter.getProject_name());
		}
		long end = System.currentTimeMillis();
		System.out.println("***************添加到list集合完成,耗时 "+(end-start)+ " 毫秒*******************");
		System.out.println();
	}
	
	
}










